/* Design by jason.leung, QQ,147430218, 新浪微博,@切片面包 */
function getClass(oParent, sClass) {
    var value = [];
    var Ele = oParent.getElementsByTagName('*');
    for (var i = 0; i < Ele.length; i++) {
        var aClass = Ele[i].className.split(' ');
        for (n = 0; n < aClass.length; n++) {
            if (aClass[n] == sClass) {
                value.push(Ele[i]);
            }
        }
    }
    return value;
}

function getStyle(obj, name) {
    if (obj.currentStyle) {
        return obj.currentStyle[name];
    }
    else {
        return getComputedStyle(obj, false)[name];
    }
}
function Running(obj, json, fnEnd) {
    clearInterval(obj.timer);
    obj.timer = setInterval(function () {
        var now = 0;
        var bStop = true;
        for (var attr in json) {
            if (attr == 'opacity') {
                now = Math.round(parseFloat(getStyle(obj, attr)) * 100);
            }
            else {
                now = parseInt(getStyle(obj, attr));
            }
            var speed = (json[attr] - now) / 5;
            speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
            if (now != json[attr]) bStop = false;
            if (attr == 'opacity') {
                obj.style.filter = 'alpha(opacity:' + now + speed + ')';
                obj.style.opacity = (now + speed) / 100;
            }
            else {
                obj.style[attr] = speed + now + 'px';
            }
        }
        if (bStop) {
            clearInterval(obj.timer);
            if (fnEnd) fnEnd();
        }
    }, 30);
}
window.onload = function () {
    var oBoxx = document.getElementById('boxx');
    var oTitle_tt = getClass(oBoxx, 'title_tt');
    var closed = '关闭窗口';
    var opened = '联系我们';
    var i = 0;

    oTitle_tt[0].onmouseover = function () {
        i++;
        (i % 2) ? Running(oBoxx, { right: 0 }, function () {
            //全屏遮罩
            showBg();
            oTitle_tt[0].innerHTML = closed;


        })
		: Running(oBoxx, { right: -200 }, function () {
		    oTitle_tt[0].innerHTML = opened;
		    closeBg();
		});
    }
}
function showBg() {
    var bh = $("body").height();
    var bw = $("body").width();
    $("#fullbg").css({
        height: bh,
        width: bw,
        display: "none"
    });
    $("body").attr("Enabled", true);
}
function closeBg() {
    $("#fullbg").hide();
    $("body").attr("Enabled", false);
}